// 遍历抛出的路由数组，生成路由结构
import routerconfig from "./RouterConfig";
import {Route,Routes,BrowserRouter,Navigate} from "react-router-dom"
let RouterView = ()=>{
    let renderRoute = (routerconfig) => {
        return routerconfig.map((item,index)=>{
            return  item.path ? <Route path={item.path} key={index} element={<item.element></item.element>}>
                    {
                        item.children && renderRoute(item.children)
                    }
            </Route>: <Route path={item.from} element={<Navigate to={item.to}></Navigate>}></Route>
        })
    }
    return (
        <BrowserRouter>
            <Routes>
                {
                    renderRoute(routerconfig)
                }
            </Routes>
        </BrowserRouter>
    )
}
export default RouterView